package Thread;

public class Demo26 {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Object locker2 = new Object();

        Thread t1 = new Thread(() -> {
            synchronized (locker){
                System.out.println("t1 等待之前");
                try {
                    locker.wait(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1 等待之后");
            }
        });

        Thread t2= new Thread(() -> {
            synchronized (locker2){
                System.out.println("t2 等待之前");
                try {
                    locker2.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t2 等待之后");
            }
        });


        Thread t3 = new Thread(() -> {
            synchronized (locker2){
                System.out.println("t3 通知之前");
                locker2.notify();
                System.out.println("t3 通知之后");
            }
        });

        t1.start();
        t2.start();
        Thread.sleep(50);
        t3.start();
    }
}
